import java.sql.SQLOutput;

public class Text {
    public static void main(String[] args) {
        //字符串的定义和赋值
        String str1="hello";
        String str2=new String("hello");
        char[] chars = {'a','b','c','e'};
        String str3 = new String(chars);//将字符数组转变为字符串输出
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
        System.out.println("==============");
        //输出字符串长度
        System.out.println(str1.length());
        System.out.println(str2.length());
        System.out.println("==============");
        String str4=str1;
        System.out.println(str4);
        String str5="";
        System.out.println(str5.isEmpty());//判断字符串是否为空
        System.out.println("hello world".length());//直接求字符串的大小，空格也算
        System.out.println("===========");
        //比较字符串的内容用equals
        String str6="abcd";
        String str7="abcd";
        System.out.println(str6.equals(str7));//内容相同返回true,否则返回false
        System.out.println("============");
        //比较字符串的大小compareTo,忽略大小写用compareToIgnoreCase
        String str8="abcdef";
        String str9="abef";
        System.out.println(str8.compareTo(str9));//8大于9的返回正数，小返回负数，等于返回0
        String str10="aBef";
        System.out.println(str9.compareToIgnoreCase(str10));

    }
}
